<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/taglibs.jspf" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><spring:message code=""/></title>
    <meta name="decorator" content="form"/>
    <style>
        .table > thead > tr > th,
        .table > tbody > tr > th,
        .table > tfoot > tr > th,
        .table > thead > tr > td,
        .table > tbody > tr > td,
        .table > tfoot > tr > td {
            vertical-align: middle;
        }
    </style>
</head>

<body class="white-bg">
<input type="hidden" id="workNoHidden">
<div class="layui-fluid">
    <div class="layui--col-sm12">
        <div class="layui-row">
            <div id="" class="layui-col-sm12">
                <div class="search-group">
                    <label class="search-label">工号：</label>
                    <span class="search-textbox">
					  <input type="text" placeholder="工号" onchange="getNameByWorkNo()" condition="eq" id="workNo">
					  </span>
                    <label class="search-label">同意书编号：</label>
                    <span class="search-textbox">
					  <input type="text" placeholder="同意书编号" onchange="confirmConsent()" condition="eq" id="consentNo">
					  </span>
                </div>
            </div>
            <grid:grid id="groupGridId1" height="190px" url="${appPath}/consent/manage/getConfirmList" caption="已确认同意书"
                       multiselect="false">
                <grid:column label="consent.manage.consentNo" name="consentNo" query="false"/>
                <grid:column label="consent.manage.patientCode" name="patientCode" query="false"/>
                <grid:column label="consent.manage.patientName" name="patientName" query="false"/>
                <grid:column label="consent.manage.age" name="age" query="false" width="70"/>
                <grid:column label="consent.manage.sex" name="sex" query="false" width="70" dict="sex"/>
                <grid:column label="consent.manage.patientAbo" name="patientAbo" query="false" dict="aboType"/>
                <grid:column label="consent.manage.patientRh" name="patientRh" query="false" dict="rhType"/>
                <grid:column label="consent.manage.confirmor" name="confirmor" query="false" redis="userCache"/>
                <grid:column label="consent.manage.confirmTime" name="confirmTime" query="false"/>
                <grid:column label="consent.manage.isConfirm" name="isConfirm" query="false" queryMode="select"
                             dict="confirmState"/>
            </grid:grid>
        </div>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui--col-sm12">
            <grid:grid id="groupGridId2" url="${appPath}/consent/manage/getNoConfirmList" height="190px" caption="未确认同意书"
                       multiselect="false">
                <grid:column label="consent.manage.consentNo" name="consentNo" query="false"/>
                <grid:column label="consent.manage.patientCode" name="patientCode" query="false"/>
                <grid:column label="consent.manage.patientName" name="patientName" query="false"/>
                <grid:column label="consent.manage.age" name="age" query="false" width="70"/>
                <grid:column label="consent.manage.sex" name="sex" query="false" width="70" dict="sex"/>
                <grid:column label="consent.manage.patientAbo" name="patientAbo" query="false" dict="aboType"/>
                <grid:column label="consent.manage.patientRh" name="patientRh" query="false" dict="rhType"/>
                <grid:column label="consent.manage.confirmor" name="confirmor" query="false" redis="userCache"/>
                <grid:column label="consent.manage.confirmTime" name="confirmTime" query="false" />
                <grid:column label="consent.manage.isConfirm" name="isConfirm" query="false" queryMode="select"
                             dict="confirmState"/>
            </grid:grid>
        </div>
    </div>
</div>
<script>
    function confirmConsent() {
        var workNo = $("#workNoHidden").val();
        if ("" == workNo) {
            layer.alert("请先输入工号！", {icon: 0, title: '警告'});
            return false;
        }
        var consentNo = $("#consentNo").val();
        $.post("${appPath}/consent/manage/confirmConsent", {consentNo: consentNo, workNo: workNo}, function (data) {
            if (data.ret == 0) {
                $("#consentNo").val("");
                $("#consentNo").focus();
                layer.msg(data.msg, {icon: 1, time: 1000});
//                $("#groupGridId1Grid").jqGrid("addRowData", data.extend.consentView.consentNo, data.extend.consentView);
                reloadGrid1();
                reloadGrid2();
            } else {
                layer.msg(data.msg, {icon: 2, time: 1000});
            }
        });
    }

    function getNameByWorkNo() {
        var workNo = $("#workNo").val();
        $("#workNoHidden").val(workNo);
        $.post("${appPath}/consent/manage/getNameByWorkNo", {workNo: workNo}, function (data) {
            if (data.ret == 0) {
                var realName = data.extend.realName;
                $("#workNo").val(realName);
                $("#consentNo").focus();
            } else {
                layer.msg("查无此用户", {icon: 2, time: 1000});
            }
        });
    }
    function reloadGrid1() {
        $("#groupGridId1Grid").jqGrid("clearGridData");
        $("#groupGridId1Grid").jqGrid('setGridParam', {
            url: "${appPath}/consent/manage/getConfirmList",
            datatype: 'json',
        }).trigger('reloadGrid');
    }


    function reloadGrid2() {
        $("#groupGridId2Grid").jqGrid("clearGridData");
        $("#groupGridId2Grid").jqGrid('setGridParam', {
            url: "${appPath}/consent/manage/getNoConfirmList",
            datatype: 'json',
        }).trigger('reloadGrid');
    }
</script>
</body>
</html>